package com.ms.content.config;

import com.ms.content.dao.MiaoshaActivityDao;
import com.ms.content.entity.MiaoshaActivityEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;

@Component
public class MyRanner implements ApplicationRunner
{
    @Autowired
    RedisTemplate redisTemplate;
    @Autowired
    MiaoshaActivityDao miaoshaActivityDao;
    @Override
    public void run(ApplicationArguments args) throws Exception {
        List<MiaoshaActivityEntity> miaoshaActivityEntities = miaoshaActivityDao.selectList(null);
        for (MiaoshaActivityEntity miaoshaActivityEntity : miaoshaActivityEntities) {
//            redisTemplate.boundHashOps("aaa").put(miaoshaActivityEntity.getId().toString(),miaoshaActivityEntity.getFlag());
            HashMap<Long, Integer> map = new HashMap<>();
            map.put(miaoshaActivityEntity.getId(),miaoshaActivityEntity.getXg());
      //      redisTemplate.opsForHash().putAll(miaoshaActivityEntity.getId(),map);
        }
    }
}
